#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int maxa = INT_MIN;
  int h = 0;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > maxa) {
      maxa = a;
      h = b;
    }
  }
  cout << h + maxa << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }

  return 0;
}